package com.itany.corejava.day04;

public class Test7 {

    public static void main(String[] args) {

        System.out.println(rint(2.6));
        System.out.println(rint(2.7));
        System.out.println(rint(6.1));
        System.out.println(rint(8.4));

        System.out.println(Test7.rint(2.6));

    }




    public static int rint(double num){

        if(num<0){
            System.out.println("只能对正数做四舍五入");

            return -1;//后期使用异常解决，暂时只是为了语法通过
        }


        int result = (int) (num + 0.5);

        return result;

    }


}
